package exhibition.app.nexd.cn.presenter;

import android.content.Context;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import exhibition.app.nexd.cn.application.NexdApplication;
import exhibition.app.nexd.cn.model.OrderForm;
import exhibition.app.nexd.cn.ui.ivew.IOrderDetailActivityView;

/**
 * Created by wangxu on 16/4/21.
 */
public class OrderDetailPresenter extends BasePresenter<IOrderDetailActivityView> {

    List<OrderForm> orderForms = new ArrayList<>();

    public OrderDetailPresenter(Context context, IOrderDetailActivityView iView) {
        super(context, iView);
    }

    public void calculationOrder() {
        double totalPrice = 0;
        for (Map.Entry<Integer, OrderForm> entry : NexdApplication.getInstance().getOrderFormMap().entrySet()) {
            OrderForm orderForm = entry.getValue();
            if (orderForm.getNum() > 0) {
                orderForms.add(orderForm);
                totalPrice += orderForm.getNum() * orderForm.getPrice() + orderForm.getHireDeposit();
            }
        }
        iView.setTotalPrice(totalPrice);
    }

    public List<OrderForm> getOrderForms() {
        return orderForms;
    }
}
